home *** CD-ROM | disk | FTP | other *** search
- ###############################################################################
- # $Id: listing.tk,v 1.3 1995/06/30 17:20:20 bmott Exp $
- ###############################################################################
- # listing.tk - Routines to handle the program listing window
- #
- # Copyright 1993
- # Bradford W. Mott
- # November 13,1993
- ###############################################################################
- # $Log: listing.tk,v $
- # Revision 1.3 1995/06/30 17:20:20 bmott
- # Problem with selecting cancel when loading a file fixed
- # (Used to wipe out the address table!)
- #
- # Revision 1.2 1994/09/13 23:27:14 bmott
- # Changed the file selector calls to use BtkFileSelector
- # Modified the algorithm to select lines to highlight
- #
- # Revision 1.1 1994/02/18 20:29:21 bmott
- # Initial revision
- #
- ###############################################################################
-
- ###############################################################################
- # Refresh the listing
- ###############################################################################
- proc RefreshProgramListing {} {
- global programListingAddressTable
-
- ## Make sure the program listing window exists
- if {[winfo exists .programListing]==0} {return}
-
- ## Get the Program Counter's name
- PutLine "ListPCRegisterName"
- set pc_name [lindex [GetList] 0]
-
- ## Get the Program Counter's value
- PutLine "ListRegisterValue $pc_name"
- scan [lindex [GetList] 0] "%s" pc
- set pc [string tolower $pc]
-
-
- ## Remove highlight from old lines
- .programListing.pack.text tag remove LineSelectTag 0.0 end
-
- ## Highlight each of the lines
- catch {
- foreach i $programListingAddressTable($pc) {
- .programListing.pack.text tag add LineSelectTag $i.0 $i.1000
- }
-
- ## Move the view to the last highlighted line
- .programListing.pack.text yview -pickplace [expr $i].0
- }
-
- }
-
- ###############################################################################
- # Load a listing into the text window
- ###############################################################################
- proc LoadProgramListing {} {
- global programListingAddressTable
-
- set name [BtkFileSelector -text "Select program listing to load:" \
- -in .programListing]
-
- if {$name!=""} {
- if {[file isdirectory $name]} {
- ChildAlertDialog ".programListing" {ERROR: The name specified was a directory!!!}
- return
- }
-
- if {[file exists $name]==0} {
- ChildAlertDialog ".programListing" {ERROR: That file does not exists!!!}
- return
- }
-
- ## Remove the Address Table array
- catch {unset programListingAddressTable}
-
- ## Open the file
- set file [open $name]
-
- ## Empty the text widget
- .programListing.pack.text delete 1.0 end
-
- .programListing.pack.text insert end "\nFile: $name\n\n"
- .programListing.pack.text tag add FilenameTag "end - 2 line linestart" \
- "end - 2 line lineend"
-
- ## Insert listing in the text widget
- while {1} {
- if {[gets $file line] != "-1"} {
- if {[scan $line "%s" address] == "1"} {
- set address [string tolower $address]
- scan [.programListing.pack.text index end] "%d" lineNumber
- .programListing.pack.text insert end "$line\n"
- catch {lappend programListingAddressTable($address) $lineNumber}
- }
- } else {
- break
- }
- }
- close $file
-
- RefreshProgramListing
- }
- }
-
- ###############################################################################
- # Close the program listing window
- ###############################################################################
- proc CloseProgramListing {} {
- catch {destroy .programListing}
- }
-
- ###############################################################################
- # Create and display the program listing window
- ###############################################################################
- proc OpenProgramListing {} {
- global ProgramListing
-
- ## Destroy the window if it exists
- catch {destroy .programListing}
-
- ## Create the top level window
- toplevel .programListing
- wm title .programListing "Program Listing"
- wm iconname .programListing "Program Listing"
- wm grid .programListing 1 1 1 1
-
- ## Create the text widget to display the program listing in
- frame .programListing.pack
- text .programListing.pack.text -relief raised -borderwidth 2 \
- -cursor left_ptr -wrap none \
- -yscrollcommand ".programListing.pack.yscroll set"
- .programListing.pack.text tag configure LineSelectTag -foreground White \
- -background Black
- .programListing.pack.text tag configure FilenameTag -foreground Red \
- -underline 1
- bind .programListing.pack.text <Any-KeyPress> "NOP"
- bind .programListing.pack.text <Any-ButtonPress> "NOP"
- bind .programListing.pack.text <Any-Motion> "NOP"
- bind .programListing.pack.text <Any-Double-ButtonPress> "NOP"
-
- ## Create scroll bar for text window
- scrollbar .programListing.pack.yscroll -relief raised \
- -command ".programListing.pack.text yview"
- pack .programListing.pack.yscroll -side left -fill y
- pack .programListing.pack.text -side left -fill both -expand 1
-
- ## Create buttons
- button .programListing.load -text "Load..." \
- -command {LoadProgramListing}
- button .programListing.clear -text "Clear" \
- -command {.programListing.pack.text delete 1.0 end}
- button .programListing.dismiss -text "Dismiss" \
- -command CloseProgramListing
-
- pack .programListing.pack -side top -fill both -expand 1 -padx 2 -pady 2
- pack .programListing.load -side left -fill x -expand 1 -padx 4 -pady 2
- pack .programListing.clear -side left -fill x -expand 1 -padx 4 -pady 2
- pack .programListing.dismiss -side left -fill x -expand 1 -padx 4 -pady 2
- }
-
-